<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>等待领取收益</title>
    <link rel="stylesheet" href="/index/css/common.css?v=2">
    <link rel="stylesheet" href="/index/css/wait_profit.css">
</head>
<body>
<div class="tabsBox">
    <div class="topTab">
        <div class="tabLeft">
            <img src="/index/assets/left.png">
        </div>
        <div class="tabCenter">待领取收益</div>
        <div class="tabRight jilu tabRight">收益说明</div>
    </div>
</div>
<div class="profit">
    <div class="profitTop cleardrift">
        <div class="profitDetail">
            <div class="profitTitle">当前可领收益</div>
            <div class="profitNum">{$user.earnings}元</div>
            <div class="profitState zhijie">直接领取</div>
        </div>

        <div class="profitDetail">
            <div class="profitTitle">最高收益</div>
            <div class="profitNum">{$top_level}元</div>
            <a href="{:url('mine/salesLevel',['reg'=>2])}" class="profitState shengji">升级会员</a>
        </div>
    </div>

    <div id="record" style="width:100%;">
        <!--<div class="profitInfor">-->
        <!--<div class="userInfor">-->
        <!--<div class="userLeft">-->
        <!--<div class="userPhone">112313132</div>-->
        <!--<div class="userTime">12-12 10:32</div>-->
        <!--</div>-->
        <!--<div class="userMore">-->
        <!--<p>最高奖励</p>-->
        <!--<p class="userMoney">66元</p>-->
        <!--</div>-->
        <!--</div>-->
        <!--<div class="userList">-->
        <!--<div class="listDetail">-->
        <!--<div class="listTitle">充值金额</div>-->
        <!--<div class="listMore">100.0</div>-->
        <!--</div>-->
        <!--<div class="listDetail">-->
        <!--<div class="listTitle">当前奖励</div>-->
        <!--<div class="listMore">32.3元<span>(10%)</span></div>-->
        <!--</div>-->
        <!--<div class="listDetail">-->
        <!--<div class="listTitle">与我关系</div>-->
        <!--<div class="listMore">直接</div>-->
        <!--</div>-->
        <!--</div>-->
        <!--</div>-->
    </div>

    <div id="load-text" style="text-align: center;color:#bbb"></div>

</div>
<div class="intiveBtn">
    <a class="invite" href="{:url('mine/invite')}">邀请用户获得收益</a>
</div>

<div class="shuoming">
    <div class="cleardrift">
        <img src="/index/assets/close.png" class="close cleardrift">
    </div>
    <div>{$help.content|raw}</div>
</div>

<div style="height:50px;"></div>
{include file='common/toast'}
</body>
<script type="text/javascript" src="/index/js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="/index/js/common.js"></script>
<script>


    $(function () {

        //领取收益
        var zj = true;
        $('.zhijie').click(function(){
            if(zj==false){
                return;
            }
            zj = false;

            $.get('{:url("gainMoney")}','',function(res){

                zj = true;
                if(res.code==1){
                    toastSuccess('领取成功','{:url("wallet")}')
                }else{
                    toastFail(res.msg);
                }
            },'json')
        })


        $('.tabRight').click(function () {
            $('.shuoming').fadeIn(500)
            $.get('{:url("explain/helpHits",["id"=>$help.id])}','',function(){})
        })
        $('.close').click(function () {
            $('.shuoming').fadeOut(500)
        })

        var page = 1
        var flag = 0;
        var is_end = 0
        getList();

        //获取邀请好友列表
        function getList() {

            if (flag == 1) {
                return;
            }

            flag = 1;

            $('#load-text').text('加载中...');
            $.get('{:url("getEarningsList")}', {page: page}, function (res) {

                if (res.code == 0) {
                    toastFail(res.msg);
                    return;
                }
                var list = res.data.data;

                $('#load-text').text('');

                for (k in list) {


                    var gx = list[k]['gx']==1?'直接':'间接';

                    var ratio = parseInt(list[k].money/list[k].pay_money*100)+'%';


                    var _html = ' <div class="profitInfor">';

                    _html += '<div class="userInfor">'
                    _html += '<div class="userLeft">'
                    _html += '<div class="userPhone">'+list[k].nickname+'</div>'
                    _html += ' <div class="userTime">'+list[k].create_time+'</div>'
                    _html += ' </div>'
                    _html += '<div class="userMore">'
                    _html += '<p>最高奖励</p>'
                    _html += ' <p class="userMoney">'+list[k].max_money+'元</p>'
                    _html += ' </div>'
                    _html += ' </div>'
                    _html += ' <div class="userList">'
                    _html += '  <div class="listDetail">'
                    _html += '  <div class="listTitle">充值金额</div>'
                    _html += '  <div class="listMore">'+list[k].pay_money+'</div>'
                    _html += ' </div>'
                    _html += ' <div class="listDetail">'
                    _html += ' <div class="listTitle">当前奖励</div>'
                    _html += ' <div class="listMore">'+list[k].money+'元<span>('+ratio+')</span></div>'
                    _html += ' </div>'
                    _html += ' <div class="listDetail">'
                    _html += '  <div class="listTitle">与我关系</div>'
                    _html += '  <div class="listMore">'+gx+'</div>'
                    _html += '  </div>'
                    _html += '  </div>'
                    _html += '  </div>'


                    $("#record").append(_html);

                }

                if(res.data.last_page==0){
                    is_end = 1;

                    $('#load-text').text('暂无收益~');
                    $('#load-text').css('margin-top','20%')
                    return;
                }

                if (res.data.current_page >= res.data.last_page) {
                    is_end = 1;
                    $('#load-text').text('已加载全部');

                    return;
                }

                page++;
                flag = 0;

            }, 'json')
        }


        $(window).scroll(function () {

            if (is_end == 0) {

                //当时滚动条离底部60px时开始加载下一页的内容
                if (($(window).height() + $(window).scrollTop() + 60) >= $(document).height()) {

                    getList();
                }
            }

        });


    })

</script>
<!-- 获取文本的值 -->
<!-- tel.substr(0,3)+"****"+tel.substr(7);
userPhone -->
</html>